package com.example.demo.model;

import com.example.demo.enums.ResultStaust;
import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private T data;
    private String ErrMsg;
    private ResultStaust status;

    public static <T> Result<T> success(T data){
        Result result=new Result();
        result.setStatus(ResultStaust.SUCCESS);
        result.setData(data);
        result.setErrMsg("");
        result.setCode(200);
        return result;
    }

    public static <T> Result<T> fail(String errMsg){
        Result result=new Result();
        result.setStatus(ResultStaust.FAIL);
        result.setCode(-1);
        result.setErrMsg(errMsg);
        return result;
    }
}
